package com.dong.common.pojo;

import com.dong.common.constant.CodeConst;
import lombok.*;

/**
 * @description:
 * @author: 陈瑞东
 * @create: 2021-08-25 15:28
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultVO<T> {

    private boolean success; // 是否成功
    private String code; // 返回码
    private T data; // 数据
    private String message; // 提示信息

    public static <T> ResultVO<T> success(T data, String message) {
        return new ResultVO<T>(true, CodeConst.CODE_SUCCESS, data, message);
    }

    public static <T> ResultVO<T> success(T data) {
        return success(data, null);
    }

    public static <T> ResultVO<T> fail(String message) {
        return fail(message, null);
    }

    public static <T> ResultVO<T> fail(String message, String code) {
        return new ResultVO(false, code, null, message);
    }

}
